﻿using System.Xml;
using Blackbird.Common.Properties;
using Blackbird.Core.Editable.Base;
using Blackbird.Core.Editable.Frames;

namespace Blackbird.Core.Editable.Sprites
{
    public class EditableMultisprite : EditableEntityCollection<EditableFramesetList>
    {
        protected override void ReadXmlContent(XmlReader reader)
        {
            Clear();
            reader.ReadStartElement("framesetsLists");
            reader.MoveToContent();
            while (reader.NodeType != XmlNodeType.EndElement) {
                var list = new EditableFramesetList();
                list.ReadXml(reader);
                Add(list);
            }
            reader.ReadEndElement();
        }

        protected override void WriteXmlContent(XmlWriter writer)
        {
            writer.WriteStartElement("framesetsLists");
            foreach (EditableFramesetList list in this)
                list.WriteXml(writer);
            writer.WriteEndElement();
        }

        public override string TypeName
        {
            get { return Resources.EditableMultiSpriteTypeFriendlyName; }
        }

        protected override void ReadXmlAttributes(XmlReader reader)
        {
        }

        protected override void WriteXmlAttributes(XmlWriter writer)
        {
        }
    }
}